﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Runtime.Remoting.Messaging;

namespace NLite.Collections
{
    /// <summary>
    /// 
    /// </summary>
    public interface IDataCollection
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        object this[object key] { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool ContainsKey(object key);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        void Remove(object key);

        /// <summary>
        /// 
        /// </summary>
        int Count { get; }

        /// <summary>
        /// 
        /// </summary>
        void Clear();
    }

    /// <summary>
    /// 
    /// </summary>
    [Contract]
    public interface IApplication : IDataCollection { }

    /// <summary>
    /// 
    /// </summary>
    [Contract]
    public interface ICache : IDataCollection { }

    /// <summary>
    /// 
    /// </summary>
    [Contract]
    public interface ISession : IDataCollection { }

    /// <summary>
    /// 
    /// </summary>
    public interface IDataContext
    {
        /// <summary>
        /// 
        /// </summary>
        IDataCollection Data { get; }
    }

   

    //public sealed class CallDataContext : MarshalByRefObject, IDataContext
    //{
    //     private const string Key = "NLite.CallDataContext";

    //    public CallDataContext():this(true)
    //    {
    //    }

    //    public CallDataContext(bool initContextData)
    //    {
    //        if(initContextData)
    //            CallContext.SetData(Key, null);
    //    }

    //    public override object InitializeLifetimeService()
    //    {
    //        return null;
    //    }

    //    public IDataCollection Data
    //    {
    //        get
    //        {
    //            var data = (IDataCollection)CallContext.GetData(Key);
    //            if (data == null)
    //            {
    //                data = new HashtableDataCollection();
    //                CallContext.SetData(Key, data);
    //            }
    //            return data;
    //        }
    //    }
    //}
}
